-
Definitions:
-
"Structural design patterns explain how to assemble objects and classes into larger structures, while keeping these structures flexible and efficient."
-
"Structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships among entities."
-
-
Comparison between Structural Patterns .
-
A comparison between Adapter, Facade, Proxy, Decorator and Bridge is made.
-
{1:42 -> 10:10}
-
Brief explanations of the patterns and UML drawings.
-
The rest of the video is just discussion about the drawings.
-
-
-
Comparison between Composite Pattern and Decorator Pattern .
-
Both use recursion and have a very similar UML diagram, with the difference that "the Decorator uses Abstractions in the definition of the Decorator, while the Composite uses Concretions" (nah, I didn't care enough about these methods to care).
-
"For a Decorator to be a Decorator, it needs to Decorate something, only one thing, to be specific. If you have a Decorator that decorates many things, you'll have a Composite Pattern, not a Decorator Pattern."
-
The idea is that if a "Decorator decorates many things", you create a Tree system.
-
-
Decorator Pattern
-
The pattern is based on "wrapping" an object in other objects to change the internal behavior at runtime.
-
-
{~28:30}
-
It becomes clearer what the idea of this pattern is: It uses a recursive system where the Wrapper calls what is inside it recursively, and at each interaction modifications are made to the final return of the function.
-
-
{37:00}
-
Code examples are shown, also helping a lot to understand the pattern.
-
-
{43:37}
-
It is shown how the coffee example used by the book is ultra over-engineering, being unnecessary and confusing; the presenter simply suggests using a list of ingredients and iterating the list.
-
-
-
Review :
-
I did not like this pattern, it feels like over-engineering in many moments.
-
Adapter Pattern
-
Also known as a 'Simple Wrapper'.
-
Makes two incompatible interfaces compatible, just like a plug adapter.
-
Review :
-
Useful only for cases of creating compatibility between two things, very specific.
-
Facade Pattern
-
Creates a "disguise" for complex interactions in the code to make interaction more friendly.
-
-
Implementation was not necessarily explained, just a discussion about the subject.
-
-
Review :
-
It seems like a kind of 'macro' to communicate with complex things or to create complex things.
-
Its use is interesting, but it gives me the impression that if you have to use this kind of thing, the code is huge and messy.
-
Proxy Pattern
-
"Adds behavior to an object, with the intent to control access to that object".
-
-
{24:09 -> 27:02}
-
The UML diagram is explained, showing the relationship between the Object, the Interface and the Proxy.
-
-
From what I understand, the Proxy implements the same Interface as the Object while also holding a reference to the Object. This allows the Proxy to control access to the Object if the function call is made through the Proxy.
-
The presenter says "it's like caching".
-
I did not understand why the Proxy must implement the Object's Interface.
-
-
-
Review :
-
Seems useful for access control and greater control of the object, but I found the pattern a bit confusing due to the Proxy's use of the Interface.
-
Bridge Pattern
-
I did not understand this pattern very well.
-
The pattern seems to have a rather loose definition, kind of whatever.
-
Review :
-
It seems to make a mess to ~fix communication between classes, apparently. It's a pattern that makes me question whether its use is only for cases where a design is poorly structured.
-
I didn't find anything useful, but maybe if I understood it better I would change my mind.
-
Composite Pattern
-
It is based on the idea of Root and Leaf, where a Root is something that has children and a Leaf is something that has no children.
-
In this context, it resembles the Decorator Pattern (and a bit the Strategy Pattern), since the entire Tree of a Root characterizes that Root, acting like a pseudo-wrap, reminding of the Decorator Pattern.
-
Although it sounds similar to a Finite State Machine, that is not actually the case, since a Root's children do not characterize 'states', but only characteristics of that Root, making it closer to the Strategy Pattern than a Finite State Machine.
-
-
The presenter spent most of the video discussing the 'add' and 'remove' functions of the components, discussing how this breaks the "Interface segregation principle".
-
The example used in the video is quite confusing, being an example of 'to-dos in html'.
-
-
Review :
-
This pattern only makes sense to use when dealing with some hierarchical organization.
-
It is very similar to the Decorator, so since I didn't like the Decorator much, I didn't like this one much either.
-